import pymysql
import pandas as pd
import numpy as np
# 连接数据库
conn = pymysql.connect(host='localhost', user='root', passwd='459gjy217', db='test', charset='utf8')
cur = conn.cursor()
# 查询数据库里面的指定表中的指定列
sqlcom = 'select 赛季,篮板,得分,助攻 from 常规赛'
df = pd.read_sql(sqlcom, con=conn)
# print(df)
# print(type(df))  # <class'pandas.core.frame.DataFrame'>
df1 = np.array(df)  # 先使用array()将DataFrame转换一下
df2 = df1.tolist()  # 再将转换后的数据用tolist()转成列表
print(df2)
for i in range(0, len(df2)):
    for j in range(0,4):
        ps_para = df2[i][j]
        print(ps_para)
# 关闭数据库连接
conn.close()
